﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ST.Model;

namespace ShowTime
{
    public partial class BuySelectGoods : Form
    {
        private List<GoodsInfo> list = new List<GoodsInfo>();
        public BuySelectGoods(List<GoodsInfo> a)
        {
            InitializeComponent();
            list = a;
        }

        public GoodsInfo Goods { get; set; }

        private void dgvSelectGoods_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (dgvSelectGoods.SelectedRows.Count == 1)
                {
                    int index = dgvSelectGoods.SelectedRows[0].Index;
                    Goods = list[index - 1];
                    this.Close();
                }
            }
        }

        private void BuySelectGoods_Load(object sender, EventArgs e)
        {
            dgvSelectGoods.AutoGenerateColumns = false;

            dgvSelectGoods.DataSource = new BindingList<GoodsInfo>(list);

        }
    }
}
